import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 05 - 13
 * Time: 21:38
 */
class UserPasswordException extends Exception {
    public UserPasswordException(String message) {
        super(message);
    }
}
class UserNameException extends Exception {
    public UserNameException(String message) {
        super(message);
    }
}
public class Login {
    private static String name = "zhangsan";
    private static String password = "123456";

    public static void loginException(String name1, String password1) throws UserNameException, UserPasswordException{
        if(!name1.equals(name)) {
            throw new UserNameException("用户名错误！");
        }
        if(!password1.equals(password)) {
            throw new UserNameException("密码错误！");
        }
        System.out.println("登陆成功！");
    }
    public static void main(String[] args) {
        while(true) {
            Scanner scanner = new Scanner(System.in);
            String name1 = scanner.nextLine();
            String password1 = scanner.nextLine();
            try {
                loginException(name1, password1);
            } catch (UserNameException e) {
                e.printStackTrace();
            } catch (UserPasswordException e) {
                e.printStackTrace();
            }
        }
    }
}
